﻿@using MrCMS.ACL
@using MrCMS.ACL.Rules
@using MrCMS.Helpers
@using MrCMS.Settings
@using MrCMS.Website
@model MrCMS.Entities.Documents.Web.Webpage  
<link href="@Url.Content("~/Areas/Admin/Content/Styles/mrcms-frontendediting.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Areas/Admin/Content/Styles/jquery.mrcms-mediaselector.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Areas/Admin/Content/Styles/jquery.mrcms-mediaselector.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Areas/Admin/Content/scripts/lib/jQuery-File-Upload-9.5.2/css/jquery.fileupload.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Areas/Admin/Content/scripts/lib/jQuery-File-Upload-9.5.2/css/jquery.fileupload-ui.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Areas/Admin/Content/Scripts/lib/fancybox/jquery.fancybox.css")" rel="stylesheet" type="text/css" />

@{
    var canEditPage = CurrentRequestData.CurrentUser.CanAccess<TypeACLRule>(TypeACLRule.Edit, Model.GetType().FullName);
    
}
<div class="mrcms-admin-nav-bar">
    <a href="@Url.Action("Index", "Home")" target="_parent" class="mrcms-btn mrcms-btn-default mrcms-btn-xs">Admin</a>
    @if (canEditPage)
    {
        <a href="@Url.Action("Edit", "Webpage", new { Model.Id })" target="_parent" class="mrcms-btn mrcms-btn-xs mrcms-btn-primary">Edit</a>
        if (Model.Published)
        {
        <a id="unpublish-now" class="mrcms-btn mrcms-btn-xs  mrcms-btn-success">Unpublish</a>
        }
        else
        {
        <a id="publish-now" class="mrcms-btn mrcms-btn-xs  mrcms-btn-warning">Publish</a>
        }
    }
    @if (Model.CanAddChildren())
    {
        @Html.ActionLink("Add a child page", "Add", "Webpage", new { id = Model.Id }, new { @class = "mrcms-btn mrcms-btn-xs mrcms-btn-default" })
    }
    @Html.ActionLink("Add page", "Add", "Webpage", new { id = Model.Parent == null ? (int?)null : Model.Parent.Id }, new { @class = "mrcms-btn mrcms-btn-xs mrcms-btn-default" })

    @if (CurrentRequestData.CurrentUser.CanAccess<InlineEditingACL>("Allowed"))
    {
        <a id="enable-editing" class="mrcms-btn mrcms-btn-xs mrcms-btn-default">Inline Editing: On</a>
    }

    @if (Model.FormPostingsCount() > 0)
    {
        <a href="/Admin/Webpage/Edit/@Model.Id#postings-tab" class="mrcms-btn mrcms-btn-xs mrcms-btn-info" target="_parent">
            @Model.FormPostings.Count
            Form entr@(Model.FormPostings.Count > 1 ? "ies" : "y")
        </a>
    }
    <a href="/logout" class="mrcms-btn mrcms-btn-xs mrcms-btn-default" style="float: right;">Logout</a>
    @if (MrCMSApplication.Get<SiteSettings>().SiteIsLive)
    {
        <a href="/Admin/Settings#site-settings" class="mrcms-btn mrcms-btn-xs mrcms-btn-success" style="float: right;">Site is set live</a>
    }
    else
    {
        <a href="/Admin/Settings#site-settings" class="mrcms-btn mrcms-btn-xs mrcms-btn-warning" style="float: right;">Site is not set live</a>
    }
</div>

@Html.HiddenFor(webpage => webpage.Id)
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Editors/ckeditor/ckeditor.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Scripts/lib/store.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Scripts/mrcms/front-end-editing.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Scripts/mrcms/mrcms-media-selector.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Scripts/mrcms/media-uploader.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Scripts/lib/fancybox/jquery.fancybox.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Scripts/lib/load-image.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Scripts/lib/jQuery-File-Upload-9.5.2/js/jquery.fileupload.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Scripts/lib/jQuery-File-Upload-9.5.2/js/jquery.fileupload-process.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Scripts/lib/jQuery-File-Upload-9.5.2/js/jquery.iframe-transport.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Scripts/lib/jQuery-File-Upload-9.5.2/js/jquery.fileupload-validate.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Areas/Admin/Content/Scripts/lib/jQuery-File-Upload-9.5.2/js/jquery.fileupload-ui.js")"></script>

